<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.prime.com.tr/ui"
        xmlns:finantial="http://java.sun.com/jsf/composite/components/finantial"
        xmlns:c="http://java.sun.com/jsp/jstl/core">

    <p:panel id="add_panel" header="#{msg['finance.add.header']}">
               
        <h:panelGrid columns="4" cellpadding="0" id="grid_add" style="overflow: auto">
                      <finantial:label  for="outcome_descricao" value="#{msg['finance.label.descricao']}:"/>
                      <h:inputText id="outcome_descricao" value="#{financeBean.financeDescription}"/>
                      <finantial:label for="date_income" value="#{msg['finance.label.data']}:" required="true" style="padding-left: 10px" />
                      <p:calendar id="date_income" effectDuration="0.5" value="#{financeBean.date}" required="true" requiredMessage="#{msg['date-required']}"  pattern="dd/MM/yyyy" effect="drop"  showOtherMonths="true"  readOnlyInputText="true" locale="pt_BR" navigator="true" styleClass="calendar"  showOn="both" mindate="#{tabBean.firstYearDate}" maxdate="#{tabBean.lastYearDate}"  popupIcon="../resources/images/calendar.png"/>

                      <finantial:label for="select_tipo" value="#{msg['finance.label.tipo']}:" />
                                <h:selectOneMenu id="select_tipo" value="#{financeBean.tipoCorrete}"  styleClass="tipo">
                                <f:selectItems value="#{financeBean.tiposFinanca}" var="tipo" itemLabel="#{tipo eq financeBean.INCOME ? msg['finance.label.tipo.income'] : msg['finance.label.tipo.outcome']}" itemValue="#{tipo}"/>
                                <f:ajax execute="select_tipo" render="select_subtipo bt-add :financeTypePanel"/>
                            </h:selectOneMenu>

                      <finantial:label for="select_subtipo_#{financeBean.tipoCorrete}" required="true" value="&#160;&#160;&#160;#{msg['finance.label.subtipo']}:"/>

                      <p:outputPanel id="select_subtipo">
                          <h:column>

                              <h:selectOneMenu id="select_subtipo_income" rendered="#{financeBean.tipoCorrete eq financeBean.INCOME}"  value="#{financeBean.subtipoIncomeCorrete}"  style="margin-bottom: 3px;margin-top: 3px;margin-left: 2px;height: 21px;width: 145px;*width: 183px" required="true" requiredMessage="#{msg['required-income-type']}">
                                  <f:selectItems value="#{financeBean.subtiposIncome}" var="subtipo" itemLabel="#{subtipo.description}" itemValue="#{subtipo}"/>
                                  <f:converter converterId="incomeConveter"/>
                              </h:selectOneMenu>
                              <h:selectOneMenu id="select_subtipo_outcome" rendered="#{financeBean.tipoCorrete eq financeBean.OUTCOME}"  value="#{financeBean.subtipoOutcomeCorrete}"  style="margin-bottom: 3px;margin-top: 3px;margin-left: 2px;height: 21px;width: 145px;*width: 183px;" required="true" requiredMessage="#{msg['required-outcome-type']}">
                                  <f:selectItems value="#{financeBean.subtiposOutcome}" var="subtipo" itemLabel="#{subtipo.description}" itemValue="#{subtipo}"/>
                                  <f:converter converterId="outcomeConveter"/>
                              </h:selectOneMenu>
                              <p:commandButton value="+" immediate="true" async="true" action="#{configurationBean.cancelRemove}" update="addType:type_paneladdType" oncomplete="addType.show()" title="Clique aqui para incluir novo tipo de #{msg['finance.label.tipo.'.concat(financeBean.tipoCorrete)]}. Para gerenciar tipos utilize o menu CONFIGURAÇÔES" style="margin-left: 3px;">
                              </p:commandButton>
                          </h:column>
                      </p:outputPanel>
                            <finantial:label for="outcome_valor" value="#{msg['finance.label.valor']}:" required="true"/>

                            <h:inputText id="outcome_valor" value="#{financeBean.financeValue}"  required="true" requiredMessage="#{msg['required-value']}">
                            <f:convertNumber pattern="#,###,##0.00" currencyCode="BRL" type="currency"/>
                        <f:ajax event="blur" render="@this"/>
                        <f:validateLength minimum="0"/>
                      </h:inputText>
                      <h:inputHidden />
                      <p:commandButton value="#{msg['add-finance']}" id="bt-add" style="width: 140px!important" image="#{financeBean.tipoCorrete eq financeBean.INCOME ? 'bt-income':'bt-outcome'}" actionListener="#{financeBean.incluir}" process="grid_add,repeat_menu" update="add_panel, tab#{tabBean.currentMonthIndex},months_panel,month_#{tabBean.currentMonthIndex},:form_carroussel:grid_carroussel,messages" />
                </h:panelGrid>
       
        <table width="100%" style="padding-top: 20px">
            <tr>
                <td style="width: 10px;padding-left: 0px;">
                    <h:outputLabel value="#{msg['propagate']}:"/>
                    <div style="display: inline;">
                    <h:selectOneMenu  id="repeat_menu" value="#{financeBean.numberOfMonthToPropagate}">
                        <f:selectItem itemLabel="#{msg['propagate.select']}" noSelectionOption="true" itemValue="0"/>
                        <f:selectItem itemLabel="1 #{msg['propagate.month']}" itemValue="1"/>
                        <f:selectItem itemLabel="2 #{msg['propagate.months']}" itemValue="2"/>
                        <f:selectItem itemLabel="3 #{msg['propagate.months']}" itemValue="3"/>
                        <f:selectItem itemLabel="4 #{msg['propagate.months']}" itemValue="4"/>
                        <f:selectItem itemLabel="5 #{msg['propagate.months']}" itemValue="5"/>
                        <f:selectItem itemLabel="6 #{msg['propagate.months']}" itemValue="6"/>
                        <f:selectItem itemLabel="7 #{msg['propagate.months']}" itemValue="7"/>
                        <f:selectItem itemLabel="8 #{msg['propagate.months']}" itemValue="8"/>
                        <f:selectItem itemLabel="9 #{msg['propagate.months']}" itemValue="9"/>
                        <f:selectItem itemLabel="10 #{msg['propagate.months']}" itemValue="10"/>
                        <f:selectItem itemLabel="11 #{msg['propagate.months']}" itemValue="11"/>
                        <f:selectItem itemLabel="1 #{msg['propagate.year']}" itemValue="12"/>
                        <f:selectItem itemLabel="1 #{msg['propagate.year']} #{msg['propagate.and']} 6 #{msg['propagate.months']}" itemValue="18"/>
                        <f:selectItem itemLabel="2 #{msg['propagate.year']}s" itemValue="24"/>
                        <f:selectItem itemLabel="2 #{msg['propagate.year']}s #{msg['propagate.and']} 6 #{msg['propagate.months']}" itemValue="30"/>
                        <f:selectItem itemLabel="3 #{msg['propagate.year']}s" itemValue="36"/>
                        <f:selectItem itemLabel="5 #{msg['propagate.year']}s" itemValue="60"/>
                    </h:selectOneMenu>
                        <h:graphicImage style="margin-bottom:-4px ;margin-left: 2px" library="images" name="info1.png" id="info" title="#{msg['propagate-tip']}"/>
                    </div>
                </td>
            </tr>


              </table>
               <p:messages id="msg"/>
            </p:panel>

</ui:composition>
